﻿using HDJ.Framework.Core;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;

public class FileCheckEditor  {

    [InitializeOnLoadMethod]
    public static void FileCheckFun()
    {
        //mcs.rsp
        //string fileName = "csc.rsp";
        //string checkPath = Application.dataPath + "/" + fileName;
     
        //Check(checkPath, fileName);
        ////81-BehaviourExtend-NewBehaviourExtendScript.cs.txt
        //fileName = "81-BehaviourExtend-NewBehaviourExtendScript.cs.txt";
        // checkPath = ReflectionUtils.Assembly_UnityEditor.GetLoadedModules()[0].FullyQualifiedName;
        //checkPath = PathUtils.CutPath(checkPath, "Data", false, true);
        //checkPath += "/Resources/ScriptTemplates/"+ fileName;
        //Check(checkPath, fileName);
    }

    public  static  void  Check(string checkPath,string fileName)
    {
        //Debug.Log("checkPath :" + checkPath);
        if (!File.Exists(checkPath))
        {
            TextAsset ta = Resources.Load(PathUtils.RemoveExtension(fileName)) as TextAsset;
            if (ta == null || string.IsNullOrEmpty(ta.text))
            {
                Debug.LogError("模板不见了！！ fileName: " + fileName);
                return;
            }

            FileUtils.CreateTextFile(checkPath, ta.text);
            AssetDatabase.Refresh();
        }
    }
}
